<template>
    <div>
        <h1>门店显示列表哈哈哈</h1>
        应该付款
        <input type="text" v-model="info.m1">
        实际付款
        <input type="text" v-model="info.m2">
        <input type="button" value="查询" @click="show" class="btn btn-primary">
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>门店id</td>
                    <td>用户姓名</td>
                    <td>门店名称</td>
                    <td>门店应收款</td>
                    <td>门店实际收款</td>
                    <td>门店状态</td>
                    <td>现金收银信息</td>
                    <td>操作</td>
                </tr>
                <tr v-for="item in list" :key="item.mid">
                    <td>{{ item.mid }}</td>
                    <td>{{ item.muname }}</td>
                    <td>{{ item.msname }}</td>
                    <td>{{ item.mzmoney }}</td>
                    <td>{{ item.msmoney }}</td>
                    <td>{{ item.mzt == 1 ? '营业' : '闭店' }}</td>
                    <td>{{ item.mxmoney }}</td>
                    <td>
                        <input type="button" value="闭店" @click="start(item.mid)" class="btn btn-danger"
                            v-if="item.mzt == 1">
                        <input type="button" value="营业" @click="start(item.mid)" class="btn btn-success"
                            v-if="item.mzt == 0">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import 'bootstrap/dist/css/bootstrap.css'
import axios from 'axios'
import { ref, reactive, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import router from '@/router';
let list: any = ref([])

let info: any = reactive({
    "m1": '',
    "m2": '',
})
onMounted(() => {
    show();
})


const show = () => {
    axios({
        url: '/api/Mess/ShowM',
        method: 'get',
        params: info
    })
        .then(res => {
            list.value = res.data;
        })
        .catch(err => {
            console.log(err);
        })
}
const start = (id: any) => {
    let f = confirm('确定要修改吗?');
    if (f) {
        axios({
            url: '/api/Mess/UpdateMzt',
            method: 'put',
            params:
            {
                id: id
            }
        })
            .then(res => {
                if (res.data > 0) 
                {
                    alert('修改状态成功');
                    show();
                }
                else {
                    alert('修改状态成功');
                    return;
                }
            })
            .catch(err => {
                console.log(err);
            })
    }

}

</script>

<style scoped></style>